package com.fira.api.controller;

import com.fira.api.domain.dto.LoginDTO;
import com.fira.api.domain.dto.SysBizUserDTO;
import com.fira.api.service.IUserService;
import com.fira.common.core.domain.AjaxResult;
import com.fira.system.domain.dto.SysUserMenuDTO;
import com.fira.system.service.ISysMenuService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * 用户接口查询
 * @author henryGui
 * @version V1.0
 * @Title: UserController
 * @Package com.fira.api.controller
 * @Description: TODO
 * @date 2021-10-13 下午2:26
 */
@RestController
@RequestMapping(value = "/api/user")
public class UserController extends ApiController{


    @Autowired
    private IUserService iUserService;
    @Autowired
    private ISysMenuService sysMenuService;

    //api/user/findUserByPhone?phoneNumber=
    @ResponseBody
    @ApiOperation(value="通过手机号查询用户信息",tags={"通过手机号查询用户信息"},notes="")
    @RequestMapping(value = "/findUserByPhone", method = RequestMethod.POST)
    public AjaxResult findUserByPhone(HttpServletRequest request, String phoneNumber){
        LoginDTO login = getLogin(request);
        return iUserService.findUserByPhone(phoneNumber,login);
    }

    //api/user/findUserByPhone?phoneNumber=
    @ResponseBody
    @ApiOperation(value="查询用户列表信息",tags={"查询用户列表信息"},notes="")
    @RequestMapping(value = "/findSysUserList", method = RequestMethod.POST)
    public AjaxResult findSysUserList(HttpServletRequest request,SysBizUserDTO userDTO){
        LoginDTO login = getLogin(request);
        return iUserService.selectUserListByObj(login,userDTO);
    }

    @ResponseBody
    @ApiOperation(value="查询用户菜单信息",tags={"查询用户菜单信息"},notes="")
    @RequestMapping(value = "/getSysUserMenu", method = RequestMethod.POST)
    public AjaxResult getUserMenu(@ApiParam(name = "查询用户菜单信息入参") SysUserMenuDTO sysUserMenuDTO,HttpServletRequest request){
        LoginDTO login = getLogin(request);
        sysUserMenuDTO.setTenantId(login.getCurrentTenantId());
        sysUserMenuDTO.setUserId(login.getTeacherId());
        return AjaxResult.success("查询成功",sysMenuService.selectAppletUserMenu(sysUserMenuDTO));
    }
}
